<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>个人中心</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta http-equiv="Cache-Control" content="no-transform">
		<meta name="format-detection" content="telephone=no">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<link rel="stylesheet" href="style/css/basic.css" />
		<link rel="stylesheet" href="style/css/agent_my.css" />
		<link rel="stylesheet" href="style/css/recommend_my.css" />
		<script type="text/javascript" src="style/plugin/mui/js/mui.min.js"></script>
		<script type="text/javascript" src="style/js/jquery-1.8.3.min.js"></script>
		<script type="text/javascript" src="style/mockjs/dist/mock.js"></script>
		<script type="text/javascript" src="style/js/vue.min.js"></script>
		<script type="text/javascript" src="style/js/vue-resource.js"></script>
		<script type="text/javascript" src="style/js/basic.js"></script>
		<script src="style/js/jquery.form.js"></script>
	</head>

	<body>
		<div class="top_bg">
			<div>
				<h2>我的</h2>
			</div>
			<div class="info_data clearfix">
				<a href="javascript:;" id="userbox">
					<div class="info_txt fl">
						<span class="name"></span>
						<span class="tel">电话：<em class="telem"></em></span> 
					</div>
					<div class="info_pic fr ">
						<form id="form1" target="nm_iframe" action="http://106.12.201.55/hetai/member/changeHead" method="post" enctype="multipart/form-data"> 
							<img id="headImg">
						    <input type="file" id="upload" style="display:none" name="head"/>	
						    <input type="submit" id="sub" style="display: none;"/>
						</form>
						<iframe id="id_iframe" name="nm_iframe" frameborder="0" style="display: none;"></iframe> 
					</div>
				</a>
			</div>
		</div>
		<div></div>
		<!--list-->
		<div class="listli">
			<ul>
				<li>
					<a href="jacascript:;" class="message">我的消息</a>
				</li>
				<li>
					<a href="javascript:;" class="address">我的地址</a>
				</li>
				<li>
					<a href="javascript:;" class="recommend">工单管理</a>
				</li>
				<li>
					<a href="javascript:;" class="intergral">积分明细</a>
				</li>
				<li>
					<a href="javascript:;" class="intergral_order">积分订单</a>
				</li>
				<li>
					<a href="javascript:;" class="altermsg">修改资料</a>
				</li>
				<li>
					<a href="javascript:;" class="service">联系客服</a>
				</li>
			</ul>
<!--			<div class="loginout"><a href="login.html">退出登录</a></div>-->
		</div>
		

		<!--footer-->
		<!--footer-->
		<div class="footer" id="footer">
			<ul class="clearfix">
				<li>
					<a href='recommend_index.html' ;><i class="icon_home"></i><span>首页</span></a>
				</li>
				<li>
					<a href="recommend.html"><i class="icon_recommend"></i><span>推荐</span></a>
				</li>
				<li>
					<a href='recommend_mall.html' ;><i class="icon_integral"></i><span>积分</span></a>
				</li>
				<li>
					<a href='recommend_my.html' ;><i class="icon_my"></i><span  class="active_color">我的</span></a>
				</li>
			</ul>
		</div>
		<script>
			mui.plusReady(function(){
				var userbox=document.getElementById("userbox");
				var message=document.getElementsByClassName("message")[0];
				var recommend=document.getElementsByClassName("recommend")[0];
				var intergral=document.getElementsByClassName("intergral")[0];
				var exit=document.getElementsByClassName("loginout")[0];
				var service=document.getElementsByClassName("service")[0];
				var headImg=document.getElementById("headImg");
				var altermsg=document.getElementsByClassName("altermsg")[0];
				var record=document.getElementsByClassName("record")[0];
				var address=document.getElementsByClassName("address")[0];
				var recommend=document.getElementsByClassName("recommend")[0];
				var intergralOrder=document.getElementsByClassName("intergral_order")[0];
				var ticket=localStorage.getItem("tick")
                var sign=localStorage.getItem("sig")
				mui.ajax(domain+"/member/getInfo?t="+ticket+"&sign="+sign,{//请求用户信息
					data:{
						userId:1
					},
					dataType:"json",
					type:'post',
					timeout:10000,
					success:function(data){
						console.log(data)
						if(data.code==1){
//							userbox.innerHTML=`
//							<div class="info_txt fl">
//								<span class="name">${data.data.nickname}</span>
//								<span class="tel">电话：<em>${data.data.phone}</em></span>
//							</div>
//							<div class="info_pic fr ">
//								<img src="${data.data.head}">
//							</div>
//							`
                            $(".name").html(data.data.nickname);
                            $(".telem").html(data.data.phone);
                            headImg.src=domain2+data.data.head
						}
					}
				})
				$("#form1").attr("action",domain+"/member/changeHead?t="+ticket+"&sign="+sign)
				$("#headImg").click(function(e) {
				 	e.preventDefault();
				 	    e.stopPropagation()
				        $("#upload").click(); //隐藏了input:file样式后，点击头像就可以本地上传
				        $("#upload").on("change", function() {
				            var objUrl = getObjectURL(this.files[0]); //获取图片的路径，该路径不是图片在本地的路径
				            if (objUrl) {
				                $("#headImg").attr("src", objUrl); //将图片路径存入src中，显示出图片
				                upimg();
				                $("#sub").click() 
				            }
				        }); 
				   });
			    //建立一?可存取到?file的url
			    function getObjectURL(file) {
			        var url = null;
			        if (window.createObjectURL != undefined) { // basic
			            url = window.createObjectURL(file);
			        } else if (window.URL != undefined) { // mozilla(firefox)
			            url = window.URL.createObjectURL(file);
			        } else if (window.webkitURL != undefined) { // webkit or chrome
			            url = window.webkitURL.createObjectURL(file);
			        }  
			        return url;
			    }
			    //上传头像到服务器
			    function upimg() { 
                    $("#sub").click(function(){
                    	$("#form1").ajaxSubmit(function(data){
						  console.log(data) 
						  mui.toast(data.msg)
					    })
                    })
			        
			    }
//				exit.addEventListener("tap",function(){//退出登录
//					mui.ajax(domain+"/user/logout?t="+ticket+"&sign="+sign,{
//				    	dataType:"json",
//				    	type:"post",
//				    	timeout:10000,
//				    	headers:{'Content-Type':'application/json'},
//				    	success:function(data){	  
//				    		if(data.code==1){
////				    			alert("1")
//				    			localStorage.clear();
//				    			plus.runtime.restart()
//				    			
//				    		}else if(data.code==0){
//				    			mui.toast("退出失败，请稍后重试",{duration:"short"})
//				    		}
//				    	},
//				    	error:function(xhr,type,errorThrown){
////				    		alert(type)
//				    	}
//				    }) 
//				})
				jumporder(altermsg,"personal_data.html","") 
				jumporder(message,"message.html","")
//				jumporder(scanlist,"scan_list.html","")
				jumporder(intergral,"integral_subsidiary.html","")
				jumporder(service,"contact_service.html","") 
				jumporder(address,"address.html","")
				jumporder(intergralOrder,"integral_order.html","")
				jumporder(recommend,"recommend_manage.html","")
			})
		</script>
	</body>

</html>